package com.us.simple.common.configuration;


import com.us.simple.common.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义拦截器配置类
 *
 * @Author: wangziqian
 * @Date: 2024-05-15
 */
@Configuration
public class InterceptConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(new JwtInterceptor())
                //拦截的路径 需要进行token验证的路径
                .addPathPatterns("/**")
                //放行的路径
                .excludePathPatterns("/login", "/logout")
                .excludePathPatterns("/test/**")
                //Knife4j
                .excludePathPatterns("/swagger-resources/**","/swagger-ui.html","/favicon.ico","/doc.html","/swagger-ui/**","/v3/api-docs/**","/v2/api-docs/**","/webjars/**","/configuration/ui","/configuration/security");

    }
}
